package com.fly.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fly.common.PaginationSupport;
import com.fly.dao.TMeasureDAO;
import com.fly.model.TMeasure;
import com.fly.model.TMeasureExample;
import com.fly.service.TMeasureService;

/**
 * 
 * TMeasureService 接口实现类
 * 
 * @author 00fly
 * @version [版本号, 2018-09-11]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Service
public class TMeasureServiceImpl implements TMeasureService
{
    
    @Autowired
    private TMeasureDAO tMeasureDAO;
    
    /**
     * 查询全部
     * 
     * @return
     */
    @Override
    public List<TMeasure> queryAll()
    {
        List<TMeasure> list = tMeasureDAO.selectAll();
        return list;
    }
    
    /**
     * 根据条件分页查询
     * 
     * @param criteria 条件对象
     * @param pageNo 页号
     * @param pageSize 页大小
     * @return
     * 
     */
    @SuppressWarnings("unchecked")
    @Override
    public PaginationSupport<TMeasure> queryForPagination(TMeasure criteria, int pageNo, int pageSize)
    {
        return tMeasureDAO.queryPagingEntities(new TMeasureExample(), pageNo, pageSize);
    }
    
    /*
     * (non-Javadoc)
     * 
     * @see com.fly.service.TMeasureService#get(java.lang.Long)
     */
    @Override
    public TMeasure get(Long id)
    {
        return tMeasureDAO.selectByPrimaryKey(id);
    }
    
    /*
     * (non-Javadoc)
     * 
     * @see com.fly.service.TMeasureService#saveOrUpdate(com.fly.entity.TMeasure)
     */
    @Override
    public void saveOrUpdate(TMeasure tMeasure)
    {
        if (tMeasure.getId() != null)
        {
            tMeasureDAO.updateByPrimaryKey(tMeasure);
        }
        else
        {
            tMeasureDAO.insert(tMeasure);
        }
    }
    
    /*
     * (non-Javadoc)
     * 
     * @see com.fly.service.TMeasureService#delete(java.lang.Long)
     */
    @Override
    public void delete(Long id)
    {
        tMeasureDAO.deleteByPrimaryKey(id);
    }
}
